/*
 * Copyright (C) 2009 M. Hautle.
 * 
 * This file is part of TrackedBean.
 * 
 * TrackedBean is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * TrackedBean is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with TrackedBean. If not, see <http://www.gnu.org/licenses/>.
 */
package ch.trackedbean.copier.annotations;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import ch.trackedbean.copier.*;

/**
 * Annotaion defining that the annotated property has to be mapped.<br>
 * Use this annotation for properties holding an other bean.<br>
 * The {@link BeanMapperManager} will be used to get a corresponding {@link IBeanMapper} to convert the bean of the source property into the bean of the
 * destination property.<br>
 * A new bean will be instanciated if the destination property is <code>null</code> and the source property holds a non <code>null</code> value.<br>
 * Use {@link DeepPathMapping} if the source property is not located on the source bean itself.<br>
 * Use {@link Mappings} if you need more than one such mapping on the same property.
 * 
 * @author M. Hautle
 */
@Documented
@Target( { METHOD, FIELD })
@Retention(RUNTIME)
public @interface DeepMapping {
	/** The name of the source property. Empty String if it's the same name as the destination property. */
	String srcProperty() default "";

	/**
	 * The class from which the attribute get's copied. (If not specified the one specified in {@link SourceClass} will be assumed)
	 */
	Class<?> srcClass() default Object.class;

	/**
	 * Flag indicating if the mapping should be 'readonly' so that {@link IBeanMapper#copyDst2Src(Object, Object, IMappingContext)} will not be executed.
	 */
	boolean readOnly() default false;

	/** Flag indicating if {@link IBeanMapper#copySrc2Dst(Object, Object, IMappingContext)} should override an object hold by the destination property. */
	boolean overrideSrc() default false;

	/** Flag indicating if {@link IBeanMapper#copyDst2Src(Object, Object, IMappingContext)} should override an object hold by the destination property. */
	boolean overrideDst() default false;

	/** The type evaluator to use for {@link IBeanMapper#copySrc2Dst(Object, Object, IMappingContext)} or null. */
	Class<? extends ITypeEvaluator> srcEvaluator() default ITypeEvaluator.class;

	/** The type evaluator to use for {@link IBeanMapper#copyDst2Src(Object, Object, IMappingContext)} or null. */
	Class<? extends ITypeEvaluator> dstEvaluator() default ITypeEvaluator.class;
}
